package com.lxl.hadoop.sort;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @Author lixilin
 * @Date 2022/1/1 8:04
 * @Description
 * KEY, VALUE 是mapper的输出
 */
public class SortPartitioner extends Partitioner<FlowBean, Text> {
    @Override
    public int getPartition(FlowBean flowBean, Text phone, int numPartitions) {
        String pre = phone.toString().substring(0, 3);
        if ("136".equals(pre)) {
            return 0;
        }
        if ("137".equals(pre)) {
            return 1;
        }
        if ("138".equals(pre)) {
            return 2;
        }
        if ("139".equals(pre)) {
            return 3;
        }
        return 4;
    }
}
